﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;

namespace AdoHelper
{
    [Serializable]
    public class SerializedParameter
    {

        public SerializedParameter(DbParameter parameter)
        {
            this.f_parameterName = parameter.ParameterName;
            this.f_parameterValue = parameter.Value;
            this.f_parameterDirection = parameter.Direction;
            this.f_parameterDbType = parameter.DbType;
        }

        private string f_parameterName = "";
        public string ParameterName
        {
            get { return f_parameterName; }
            set { f_parameterName = value; }
        }

        private object f_parameterValue = null;
        public object ParameterValue
        {
            get { return f_parameterValue; }
            set { f_parameterValue = value; }
        }

        private ParameterDirection f_parameterDirection = ParameterDirection.Input;
        public ParameterDirection ParameterDirection
        {
            get { return f_parameterDirection; }
            set { f_parameterDirection = value; }
        }

        private DbType f_parameterDbType = DbType.String;
        public DbType ParameterDbType
        {
            get { return f_parameterDbType; }
            set { f_parameterDbType = value; }
        }

        public void ToParameter(DbParameter parameter)
        {
            parameter.ParameterName = this.f_parameterName;
            parameter.Value = this.f_parameterValue;
            parameter.Direction = this.f_parameterDirection;
            parameter.DbType = this.f_parameterDbType;
        }
    }
}